import yaml
import os
from common.readconfig import Environ

def get_yaml_filepath(Environ="",filepath=""):
    Environ1 = os.path.abspath(os.path.dirname(os.path.dirname(__file__)) + Environ)  # 拼接定位到data文件夹
    print("Environ1:",Environ1)
    filepath1 =os.path.abspath(os.path.dirname(os.path.dirname(__file__)) + r"/data") + "/" + filepath  # 拼接定位到data文件夹
    print("filepath1:",filepath1)
    if Environ:
        with open(Environ1, "r", encoding="utf-8")as f:
            return yaml.load(f, Loader=yaml.FullLoader)
    if filepath:
        with open(filepath1, "r", encoding="utf-8")as f:
            return yaml.load(f, Loader=yaml.FullLoader)
configs_data= get_yaml_filepath(Environ=Environ)
if __name__ == '__main__':

    print("ddd",get_yaml_filepath(Environ=Environ))
    print("ggg",get_yaml_filepath(filepath=r'member_controller\login.yaml'))
#读取测试环境和预发布环境的信息数据，比如"D:\测试之道学院\代码\kuangjia\configs\test\data.yaml"，
# class ReadYamlConfigs():
#     def __init__(self,filename):
#
#         self.filepath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)) + Environ) + "/" + filename
#
#     def get_yaml_data(self):
#         with open(self.filepath,"r",encoding="utf-8") as f:
#             return  yaml.load(f,Loader=yaml.FullLoader)
#
# #读取测试用例
# class ReadYamlData():
#     def __init__(self, filename):
#         self.filepath = os.path.abspath(os.path.dirname(os.path.dirname(__file__)) + r"/data") + "/" + filename
#
#     def get_yaml_data(self):
#         with open(self.filepath, "r", encoding="utf-8") as f:
#             return yaml.load(f, Loader=yaml.FullLoader)


